package com.itheima.publisher.config;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Slf4j
@Configuration
@RequiredArgsConstructor
public class MqConfig {
    private final RabbitTemplate rabbitTemplate;
    @PostConstruct
    public void init()
    {
        rabbitTemplate.setReturnsCallback(returned->
        {
            log.error("检测到returnCallBack");
            log.error("exchange:{}",returned.getExchange());
            log.error("routingKey:{}",returned.getRoutingKey());
            log.error("replyCode:{}",returned.getReplyCode());
            log.error("ReplyText:{}",returned.getReplyText());
            log.error("message:{}",returned.getMessage());
        });
    }
}
